from openai import OpenAI

client = OpenAI(
    base_url='http://localhost:11434/v1/',
    api_key='ollama',  # 必须传递该参数
)

prompt = "在单词\"strawberry\"中，总共有几个R？"
messages = [
    {"role": "user", "content": prompt}
]

response = client.chat.completions.create(
    model="qwen3:4b",
    messages=messages,
    stream=False,
)

print(response.choices[0].message.content)